package com.hpf.lease.web.admin.controller;

import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.LeaseTerm;
import com.hpf.lease.web.admin.service.LeaseTermService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/term")
@Tag(name = "租期管理模块")
public class TermController {
    @Resource
    LeaseTermService leaseTermService;
    @PostMapping("/saveOrUpdate")
    @Operation(summary = "根据id添加或修改租期")
    public Result<Object> saveOrUpdate(@RequestBody LeaseTerm term){
        return Result.build(leaseTermService.saveOrUpdateInfo(term));
    }
    @GetMapping("/list")
    @Operation(summary = "查询所有租期")
    public Result<List<LeaseTerm>> selectAll(){
        return Result.ok(leaseTermService.list());
    }
    @DeleteMapping("/deleteById")
    @Operation(summary = "根据id删除租期")
    public Result<Object> deleteById(@RequestParam Long id){
        return Result.build(leaseTermService.removeById(id));
    }
}
